package com.summer.data.springboot;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 345480567@qq.com
 */
@Configuration
@Import(AutoPageInterceptor.class)
public class AutoPageAutoConfigurer implements WebMvcConfigurer {

    private static final Logger logger = LoggerFactory.getLogger(AutoPageAutoConfigurer.class);

    @Autowired
    AutoPageInterceptor autoPageInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        logger.debug("加载自动分页参数拦截器");

        // 处理默认分页参数
        InterceptorRegistration pageReg = registry.addInterceptor(autoPageInterceptor);
        pageReg.addPathPatterns("/**");

    }

}
